home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1998 June / SGI IRIX 6.5 Applications 1998 June.iso / dist / outbox.idb / var / www / cgi-bin / webdist.install.cgi.z / webdist.install.cgi
Text File  |  1998-05-04  |  3KB  |  146 lines

  1. #!/usr/sbin/perl
  2. #
  3. # webdist.install.cgi
  4. #
  5. # This script is used by Web Installation Pages generated by the 
  6. # webdist utility.
  7. #
  8.  
  9. ## Copyright 1995, Silicon Graphics, Inc.
  10. ## All Rights Reserved.
  11. ##
  12. ## This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  13. ## the contents of this file may not be disclosed to third parties, copied or
  14. ## duplicated in any form, in whole or in part, without the prior written
  15. ## permission of Silicon Graphics, Inc.
  16. ##
  17. ## RESTRICTED RIGHTS LEGEND:
  18. ## Use, duplication or disclosure by the Government is subject to restrictions
  19. ## as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  20. ## and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  21. ## successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  22. ## rights reserved under the Copyright Laws of the United States.
  23.  
  24.  
  25. #
  26. # Process cgi args
  27. #
  28.  
  29. if( $ENV{'REQUEST_METHOD'} eq "GET" )
  30. {
  31.    $buffer=$ENV{'QUERY_STRING'} ;
  32. }
  33. else
  34. {
  35.    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}) ;
  36. }
  37. @pairs = split(/&/, $buffer) ;
  38. foreach (@pairs)
  39. {
  40.    tr/+/ / ;
  41.    ($name,$value)=  split(/=/) ;
  42.    $value        =~ s/%(..)/pack("c",hex($1))/ge ;
  43.    $name         =~ s/%(..)/pack("c",hex($1))/ge ;
  44.  
  45.    $in{$name} = $value;
  46.  
  47. }
  48.  
  49.  
  50.  
  51. #
  52. # Get list of products and the location of the distribution directory
  53. #
  54.  
  55. @products = sort(split(" ", $in{products}));
  56. $distdir = $in{distdir};
  57.  
  58.  
  59.  
  60. #
  61. # Collect selected products in selprods.  If none are selected -- the maximum
  62. # index is -1 -- report error.
  63. #
  64.  
  65. foreach $i (@products) {
  66.     if ($in{$i} eq "on") {
  67.         push(@selprods, $i);
  68.     $dist = $distdir . "/" . $i;
  69.     } 
  70. }
  71.  
  72.  
  73. if ( $#selprods < 0 ) {
  74.     &report_fatal_error("No products selected for installation!");
  75.  
  76. #
  77. # If the max index of selected products is not zero, there are more than 
  78. # one selected products.  Use the distribution directory as the dist location.
  79. #
  80.  
  81. if ($#selprods != 0) {
  82.     $dist = $distdir;
  83. }
  84.  
  85.  
  86.  
  87. #
  88. # Output header for inst install file type, x-install,
  89. # and the blank line needed by browser to recognize header
  90. #
  91.  
  92.  
  93. print "Content-type: application/x-install\n\n";
  94.  
  95. #
  96. # Output inst selections file header 
  97. #
  98.  
  99. print "#! /usr/sbin/SoftwareManager -F\n";
  100. print "#Tag 000109B1\n";
  101. print "from $dist\n";
  102.  
  103. #
  104. # Output resources to start installation immediately if requested
  105. #
  106.  
  107. if ( $in{options} eq "immediate" ) {
  108.     print "s automatic true\n";
  109.     print "s background false\n";
  110.     print "s interactive false\n";
  111.     print "s delayspacecheck true\n";
  112.     print "s report_exit_status false\n";
  113. }
  114.  
  115.  
  116. #
  117. # Output selections based on the value of the toggle buttons
  118. #
  119.  
  120. print "\n";
  121. foreach $i (@selprods) {
  122.     print "i $i\n";
  123. }
  124.  
  125.  
  126.  
  127. #
  128. # Report fatal error in the form of a Web page
  129. #
  130.  
  131. sub report_fatal_error {
  132.     local ($msg) = @_;
  133.  
  134.     print "Content-type: text/html\n\n";
  135.     print "<HTML>\n";
  136.     print "<TITLE>Web Installation Error</TITLE>\n";
  137.     print "</HEAD>\n";
  138.     print "<BODY>\n";
  139.     print "<H3>Web Installation Error</H3>\n";
  140.     print "$msg\n";
  141.     print "</BODY>\n";
  142.     
  143.     exit 0
  144. }
  145.